/*
	Base functions.
*/

//------------------------------------------------------------------------------//
//									HEADER										//

#include "cl.h"

// Defines //
#if DEBUG == 1
#	define __UNIQUE_ASSERT_NAME( a )				a##__LINE__
#	define	static_assert( _condition, _text )		enum { __UNIQUE_ASSERT_NAME( __static_assert_ ) = (1 / ((_condition) ? 1 : 0)) }
#	define assert( _condition )						//{ int __UNIQUE_ASSERT_NAME( __assert_ ) = (1 / ((_condition) ? 1 : 0)); }
#else
#	define	static_assert( _condition, _text )
#	define assert( _condition )
#endif

#define count_of( _array )		(sizeof(_array) / sizeof(_array[0]))


// Utils //
int3  GetGlobalCoord ();
real3 GetGlobalCoordTransformed (real3 scale, real3 bias);


//------------------------------------------------------------------------------//
//									SOURCE										//

int3 GetGlobalCoord ()
{
	int3	id    = (int3)( get_global_id(0),     get_global_id(1),     get_global_id(2)     );
	return id;
}

real3 GetGlobalCoordTransformed (real3 scale, real3 bias)
{
	int3	size  = (int3)( get_global_size(0),   get_global_size(1),   get_global_size(2)   );
	int3	id    = (int3)( get_global_id(0),     get_global_id(1),     get_global_id(2)     );
	return ( convert_real3(id) / convert_real3(size) ) * scale + bias;
}
